import { getTaskIdByUrlService, getYuyinByIdService } from '../../../util/robot/voice';

export async function getTaskIdByUrl(ctx: Context, next: Next): Promise<void> {
  const { url } = ctx.request.body;
  try {
    const result = await getTaskIdByUrlService(url);
    ctx.api.success(result, 'sucess');
  } catch (error) {
    ctx.api.fail(-1, error);
  }
  
  return next();
}

// 通过taskId获取语音识别的内容
export async function getTextById(ctx: Context, next: Next): Promise<void> {
  const { taskId } = ctx.request.body;


  try {
    const result = await getYuyinByIdService(taskId);
    ctx.api.success(result, 'sucess');
  } catch (error) {
    ctx.api.fail(-1, error);
  }
  
  return next();
}
